package com.dlwx.parttimetalent.views;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ExpandableListView;

import com.dlwx.parttimetalent.R;
import com.dlwx.parttimetalent.adapter.DialogHyyrExpandAdapter;
import com.dlwx.parttimetalent.bean.OrderRecBean;
import com.dlwx.parttimetalent.inter.DialogFilerInter;
import com.flyco.dialog.widget.base.BaseDialog;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/1/6.
 */

public class DialogFilterHyyr extends BaseDialog {
    @BindView(R.id.expand_listview)
    ExpandableListView expandListview;
    private Context context;
    private DialogFilerInter inter;
    List<OrderRecBean.BodyBean.ChildBeanX> beans;

    public DialogFilterHyyr(Context context, List<OrderRecBean.BodyBean.ChildBeanX> beans, DialogFilerInter inter) {
        super(context);
        this.context = context;
        this.beans = beans;
        this.inter=inter;
    }

    @Override
    public View onCreateView() {
        widthScale(0.92f);
//        showAnim(new Swing());
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_classify_hyyr, null);
        ButterKnife.bind(this, view);
        initView();
        return view;
    }

    private void initView() {
        DialogHyyrExpandAdapter mAdapter = new DialogHyyrExpandAdapter(beans, context, new DialogFilerInter(){

            @Override
            public void callBack(String datas, String labeid, String sex, String minage, String maxage, String distance, String filterTime) {

            }
        });
        expandListview.setGroupIndicator(null);
        expandListview.setAdapter(mAdapter);
        int width = ((Activity) context).getWindowManager().getDefaultDisplay().getWidth();
        expandListview.setIndicatorBounds(width - 100, width - 10);
        expandListview.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
            @Override
            public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
                inter.callBack(beans.get(groupPosition).getChild().get(childPosition).getLabelid()+"","","","","","","");
                DialogFilterHyyr.this.dismiss();
                return false;
            }
        });
    }

    @Override
    public void setUiBeforShow() {

    }
}
